// Defines the List of JAR Libraries
import java.util.concurrent.TimeUnit;
import org.junit.*;
import static org.junit.Assert.*;
import org.openqa.selenium.*;
// import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;

public class YtubeSearch {
	private WebDriver driver;
	private String baseUrl;
	private StringBuffer verificationErrors = new StringBuffer();
	@Before
	public void setUp() throws Exception {
		System.out.println("Begin of Before annotation");
		driver = new InternetExplorerDriver();
		//driver = new FirefoxDriver();
		baseUrl = "http://www.youtube.com/";
		driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
	}

	@Test
	public void testYtube() throws Exception {
		System.out.println("Begin of test");
		driver.get(baseUrl + "/");
		driver.findElement(By.id("masthead-search-term")).clear();
		driver.findElement(By.id("masthead-search-term")).sendKeys("QTP");
		driver.findElement(By.id("search-btn")).click();
		// ERROR: Caught exception [ERROR: Unsupported command [isTextPresent]]
		driver.findElement(By.linkText("Movies")).click();
		driver.findElement(By.linkText("Upload")).click();
		driver.findElement(By.xpath("//input[@id='Email']")).clear();
		driver.findElement(By.xpath("//input[@id='Email']")).sendKeys("zoombak");
		driver.findElement(By.xpath("//input[@id=\"signIn\"]")).click();
		driver.findElement(By.xpath("//input[@id=\"Passwd\"]")).clear();
		driver.findElement(By.xpath("//input[@id=\"Passwd\"]")).sendKeys("");
		System.out.println("End of test");
	}

	@After
	public void tearDown() throws Exception {
		driver.quit();
		String verificationErrorString = verificationErrors.toString();
		if (!"".equals(verificationErrorString)) {
			fail(verificationErrorString);
		}
	}

	private boolean isElementPresent(By by) {
		try {
			driver.findElement(by);
			return true;
		} catch (NoSuchElementException e) {
			return false;
		}
	}
}

